<?php
/* -=-=-=-=-=-=-=-=-=-=-=-=-
     author by terry
-=-=-=-=-=-=-=-=-=-=-=-=- */
error_reporting(7);
require "global.php";
cpheader();
//set offset
if(!empty($_POST[offset]))
{$offset = $_POST[offset];}
else if  (!empty($_GET[offset]))
{$offset = $_GET[offset]; }
else  {$offset = 0; }
if($_GET[action]=="del"){
    $id = $_GET[id] ;
    $sql = "DELETE FROM pa_invite WHERE in_id = '".$id."'";
	$DB->query($sql);
	$_GET[action] = "list";
}



if ($_GET[action]=="list"){


	if($_GET[action]=="list"){   
		$nav = new buildNav;

		$total = $DB->fetch_one_array("SELECT count(*) as count FROM pa_invite");

		$nav->total_result = $total[count];
 
		$by = "in_id"; 
		$order = "DESC";
        $_GET[order1]==''&&$order1=1;$_GET[order2]==''&&$order2=1;$_GET[order3]==''&&$order3=1;$_GET[order4]==''&&$order4=1;
		$_GET[order5]==''&&$order5=1;$_GET[order6]==''&&$order6=1;$_GET[order7]==''&&$order7=1;$_GET[order8]==''&&$order8=1;$_GET[order9]==''&&$order9=1;$_GET[order10]==''&&$order10=1;
		switch($_GET[swh]){
		   case 1:
			   $by = "in_id";
               if($_GET[order1]==1){$order1=2; $order=" DESC ";
			   $image1 = "<img src=\"images/dot1.gif\">";}else{$order1=1;$order=" ASC ";
			   $image1 = "<img src=\"images/dot2.gif\">";}
			   break;
           case 2:
               $by = "in_jobid";
               if($_GET[order2]==1){$order2=2; $order=" DESC ";$image2 = "<img src=\"images/dot1.gif\">";}else{$order2=1;$order=" ASC ";$image2 = "<img src=\"images/dot2.gif\">";}
			   break;
		   case 3:
                $by = "in_resumeid";
               if($_GET[order3]==1){$order3=2; $order=" DESC ";$image3 = "<img src=\"images/dot1.gif\">";}else{$order3=1;$order=" ASC ";$image3 = "<img src=\"images/dot2.gif\">";}
			   break;
		   case 4:
               $by = "in_epname";
               if($_GET[order4]==1){$order4=2; $order=" DESC ";$image4 = "<img src=\"images/dot1.gif\">";}else{$order4=1;$order=" ASC ";$image4 = "<img src=\"images/dot2.gif\">";}
			   break;	
		    case 5:
                $by = "in_rcname";
               if($_GET[order5]==1){$order5=2; $order=" DESC ";$image5 = "<img src=\"images/dot1.gif\">";}else{$order5=1;$order=" ASC ";$image5 = "<img src=\"images/dot2.gif\">";}
			   break;	
    	    case 6:
               $by = "in_rename";
               if($_GET[order6]==1){$order6=2; $order=" DESC ";$image6 = "<img src=\"images/dot1.gif\">";}else{$order6=1;$order=" ASC ";$image6 = "<img src=\"images/dot2.gif\">";}
			   break;	
		   case 7:
               $by = "in_jobtitle";
               if($_GET[order7]==1){$order7=2; $order=" DESC ";$image7 = "<img src=\"images/dot1.gif\">";}else{$order7=1;$order=" ASC ";$image7 = "<img src=\"images/dot2.gif\">";}
			   break;	
		    case 8:
               $by = "in_jobsalary";
               if($_GET[order8]==1){$order8=2; $order=" DESC ";$image8 = "<img src=\"images/dot1.gif\">";}else{$order8=1;$order=" ASC ";$image8 = "<img src=\"images/dot2.gif\">";}
			   break;
			case 9:
               $by = "in_acttime";
               if($_GET[order9]==1){$order9=2; $order=" DESC ";$image9 = "<img src=\"images/dot1.gif\">";}else{$order9=1;$order=" ASC ";$image9 = "<img src=\"images/dot2.gif\">";}
			   break;
		    case 10:
               $by = "in_status";
               if($_GET[order10]==1){$order10=2; $order=" DESC ";$image10 = "<img src=\"images/dot1.gif\">";}else{$order10=1;$order=" ASC ";$image10 = "<img src=\"images/dot2.gif\">";}
			   break;
		}

		
		$order = " ORDER BY $by $order";
		$nav->execute("SELECT  * FROM pa_invite $order");

    }
	
	echo $nav->title("Applicant list");
    echo $nav->pagenav();

    
    echo "<table border=\"0\" width=\"100%\" cellpadding=\"4\" cellspacing=\"1\" class=\"tableoutline\">
	<script type=\"text/javascript\" src=\"http://download.skype.com/share/skypebuttons/js/skypeCheck.js\"></script>
	   <tr align=\"center\" class=\"tbhead\">
	    <td nowrap  width=\"10%\"><a href=\"certification.php?action=list&offset=$_GET[offset]&order1=$order1&swh=1\">$image1 C&A ID</a></td>
	    <td nowrap  width=\"10%\"><a href=\"certification.php?action=list&offset=$_GET[offset]&order2=$order2&swh=2\">$image2 ER Job Req#</a></td>
	    <td nowrap  width=\"10%\"><a href=\"certification.php?action=list&offset=$_GET[offset]&order3=$order3&swh=3\">$image3 Candidate ID#</a></td>
	    <td nowrap  width=\"10%\"><a href=\"certification.php?action=list&offset=$_GET[offset]&order4=$order4&swh=4\">$image4 Company Name </a></td>
	    <td nowrap  width=\"10%\"><a href=\"certification.php?action=list&offset=$_GET[offset]&order5=$order5&swh=5\">$image5 Recruiter Username</a></td>
	    <td nowrap  width=\"10%\"><a href=\"certification.php?action=list&offset=$_GET[offset]&order6=$order6&swh=6\">$image6 Candidate Name</a></td>
	    <td nowrap  width=\"10%\"><a href=\"certification.php?action=list&offset=$_GET[offset]&order7=$order7&swh=7\">$image7 Job Title</a></td>
	    <td nowrap  width=\"10%\"><a href=\"certification.php?action=list&offset=$_GET[offset]&order8=$order8&swh=8\">$image8 Job Salary</a></td>
	    <td nowrap  width=\"10%\"><a href=\"certification.php?action=list&offset=$_GET[offset]&order9=$order9&swh=9\">$image9 Date/Time C&A Submitted </a></td>
	    <td nowrap  width=\"10%\"><a href=\"certification.php?action=list&offset=$_GET[offset]&order10=$order10&swh=10\">$image10 C&A Status</a></td>
	    <td>Action</td>
		</tr>\n";
    while ($list = $DB->fetch_array($nav->sql_result)){
		switch($list[in_status]){
		 case 1:
			 $st = "<Font color=green>I Agree</font>";
		 break;
		 case 2:
			 $st = "I Don't Agree";
		 break;
		 case 3:
			 $st = "<Font color=orange>Pending</font>";
		 break;
		}
		$acttime = ($list[in_acttime]=='0')?" N/A ":date('m/d/Y',$list[in_acttime]);
           echo "<tr class=".getrowbg().">
                      <td align=\"left\" >".$list[in_id]."</td>
					  <td align=\"left\" >".$list[in_jobid]."</td>
					  <td align=\"left\" >".$list[in_resumeid]."</td>
                      <td align=\"left\" >".$list[in_epname]."</td>
                      <td align=\"left\" >".$list[in_rcname]."</td>
					  <td align=\"left\" >".$list[in_rename]."</td>
					  <td align=\"left\" >".$list[in_jobtitle]."</td>
					  <td align=\"left\" >".$salary[$list[in_jobsalary]]."</td>
					  <td align=\"left\" >".$acttime."</td>
					  <td align=\"left\" >".$st."</td>
					  <td><a href=\"?action=del&id=$list[in_id]\">delete</a></td>
                </tr>";
    }
	if(empty($total[count])){
			echo "<tr><td><font color=red>No results!</font></td></tr>";
   }
    echo "</table>\n";
    echo $nav->pagenav();
}



cpfooter();
?>